<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>B2B电商平台.重置密码</title>
<%@ include file="/pages/mainPage/header.jsp" %>
<style type="text/css">
body{background:transparent;}
.login-left-img{width:602px;height:453px;overflow:hidden;}
.login-left-img a{display:block;}

</style>
 <script type="text/javascript">
 //初始化
 jQuery(function () {
	jQuery.ajaxSetup({cache:false});
	/*输入框内容改变事件，内容改变，隐藏提示*/
	jQuery(".regList .regRight input").live("change", function() {
		var thisObj = jQuery(this);
		thisObj.next("div").find(".tips-errow").hide();
		thisObj.next("div").find(".tipsCur").hide();
		thisObj.next("div").find(".tips-ok").hide();
	});
	_findPinNum();
});
</script>
</head>
 <body>
  	<!--头部分-->
 	<div class="regTop">
		<img src="<%=path %>/include/images/logo/logoB.png" style="padding-left:10px;padding-top:10px;height:40px;float:left;"/><div style="color:#C7C7C7;float:left;font-size:21px;padding-top:10px;">&nbsp;|重置登录密码 </div><span>我是会员，点此<a href="<%=path %>/login">登录</a></span>
	</div>
	<!--登录部分-->
 	<div class="regBox">
 		<div style="width:100%;border-bottom: 2px solid #e5e5e5;"></div>
		<div class="regList">
                <form id="regform" name="regform" action="" method="post">
                <input type="hidden" id="ReturnURL" name="ReturnURL" value="">
                <input type="hidden" id="curPath" name="curPath" value="<%=path %>">
                	<input type="hidden" id="pinNum" name="pinNum"  />
                <ul>
                    <li>
                        <div class="regLeft">
                            <em>*</em>用户账号：
                        </div>
                        <div class="regRight zIndex5">
                            <input  class="iText"  type="text" tabindex="1"  id="userCode" name="userCode" value="" autocomplete="off" maxlength="15" >
                        	<div class="promptBox" >
                        		<div class='tips-errow' style="display:none;">用户帐号不存在</div>
                        		<div class='tips-ok' style="display:none;"></div>
                        		<div class='tipsCur' style="display:none;">请输入用户名</div>
                        	</div>
                        </div>
                    </li>
                    <li>
                        <div class="regLeft">
                            <em>*</em>邮箱帐号：
                        </div>
                        <div class="regRight zIndex4">
                            <input class="iText" type="text" tabindex="2"  id="emailCode" name="emailCode" autocomplete="off"  value="" maxlength="25">
                        	<div class="promptBox">
                        		<div class='tips-errow' style="display:none;">用户帐号和邮箱帐号不匹配</div>
                        		<div class='tips-ok' style="display:none;"></div>
                        		<div class='tipsCur' style="display:none;">请输入邮箱帐号</div>
                        	</div>
                        </div>
                    </li>
                    <li>
                        <div class="regLeft">
                            <em>*</em>验证码：
                        </div>
                        <div class="regRight zIndex4">
		                	<input  class="iText"  tabindex="3" id="pin" name="pin" type="text" autocomplete="off"  value="" maxlength="6"/>
		                	<img id="pinpic" src = "<%=path %>/verifyCode/refresh.do?widthP=70&heightP=36" style="width:70px;height:36px;margin-left:10px;position:relative;" onclick="_refresh();"/>
		                	<a href="javascript:void('')" onclick="_refresh();" target="_self" style="margin-left:16px;position:relative;top:-10px;"  ><span style="font-size:14px;">换一张</span></a>
                        	
                        	<div class="promptBox" >
                        		<div class='tips-errow' id="E" style="display:none;">验证码输入不匹配</div>
                        		<div class='tips-ok' id="Y" style="display:none;"></div>
                        		<div class='tipsCur' id="N" style="display:none;">请输入验证码</div>
                        	</div>
                        </div>
                    </li>
                    <li>
                        <a href="####" class="botBtn" tabindex="8"  id="btnSignUp" onclick="_sendEmail()">发送邮件</a>
                    </li>
                    <li>
                        <div class="regLeft"></div>
                        <div class="regRight" >
                            <p style="display:none;">
                               	您确认阅读并接受<a href="http://my.b2b.hc360.com/my/turbine/template/firstview,regtxt.html" target="_blank">《慧聪网服务条款》</a><br>
                                <a href="http://info.kf.hc360.com/2014/11/1318391302.shtml" target="_blank">《慧聪网在线交易服务条款》</a><a href="http://info.kf.hc360.com/2014/11/1318391301.shtml" target="_blank">《慧付宝服务协议》</a>
                            </p>
                        </div>
                    </li>
                </ul>
                </form>
            </div>
		</div>
	<!--新版登录页面 End -->
	<!--  footer begin -->
	<div class="footer">
		<iframe src="<%=path %>/pages/html/main/mainFootImg.html" style="height:100px;width:755px;margin: 0 auto;overflow: hidden;" frameborder="0" scrolling="no"></iframe>
		
		<iframe width="100%" height="120" frameborder="0" src="<%=path %>/pages/html/main/mainFoot.html" scrolling="no"></iframe>
	</div>
	<!--  footer end -->
 </body>
<script type="text/javascript">
//查询验证码数值
function _findPinNum(){
	var url = '<%=path%>/verifyCode/findPinNum.do';
 	$.ajax({
        cache: true,
        type: "POST",
        url: url,
        async: false,
        dataType:"json",
        error: function(request) {
          alert('操作失败，请稍候重试!');  
        },
       success:function(data){
			if(data.success){
				var pinValue=data.obj;
				$("#pinNum").val(pinValue);
			}
		}
   });
}
//换一张
function _refresh(){
	var obj=$("#pinpic");
 	obj.attr("src","<%=path %>/verifyCode/refresh.do?widthP=74&heightP=36&t="+Math.random());
}
//发送邮件
function _sendEmail(){
	if(_checkIfTrue()){
		var userCode=$("#userCode").val();		//用户编码
		var emailAddress=$("#emailCode").val(); //邮箱帐号
//		emailAddress = emailAddress.replace("@",".E40.");
		var url = '<%=path%>/emailAuthenticate/sendEmailForResetPwd.do';
		$.ajax({
	         cache: true,
	         type: "POST",
	         url: url,
	         async: false,
	         dataType:"json",
	         data:{emailAddress:emailAddress,userCode:userCode},
	        success:function(data){
	        	if(data.success){
					swal(data.msg);
				} else {
					swal(data.msg);
				}
			},
			 error: function(request) {
	          	swal('操作失败，请稍候重试!'); 
	         }
	    });
	}
}
//验证输入是否正确
function _checkIfTrue(){
 	var userCode = $("#userCode").val();		//用户帐号
	var emailCode = $("#emailCode").val();		//邮箱帐号
	_findPinNum();
	var pin = $("#pin").val();					//输入验证码值
	var pinNum = $("#pinNum").val();			//验证码值
	if(userCode==''&&emailCode==''&&pin==''){ //验证是否填写用户帐号和邮箱帐号和验证码
		$("#userCode").next("div").find(".tips-ok").hide();
 	  	$("#userCode").next("div").find(".tips-errow").hide();
		$("#userCode").next("div").find(".tipsCur").show();
		$("#emailCode").next("div").find(".tips-ok").hide();
 	  	$("#emailCode").next("div").find(".tips-errow").hide();
		$("#emailCode").next("div").find(".tipsCur").show();
		$("#Y").hide();
		$("#E").hide();
		$("#N").show();
		return false;
	}else if(userCode==''){	 //验证是否填写用户帐号
		$("#userCode").next("div").find(".tips-ok").hide();
 	  	$("#userCode").next("div").find(".tips-errow").hide();
		$("#userCode").next("div").find(".tipsCur").show();
		return false;
	}else if(emailCode==''){ //验证是否填写邮箱帐号
		$("#emailCode").next("div").find(".tips-ok").hide();
 	  	$("#emailCode").next("div").find(".tips-errow").hide();
		$("#emailCode").next("div").find(".tipsCur").show();
		return false;
	}else if(pin==''){
		$("#Y").hide();
		$("#E").hide();
		$("#N").show();
		return false;
	}else if(pin !=''&& pinNum != ''&& pin != pinNum){
		$("#Y").hide();
		$("#N").hide();
		$("#E").show();
		return false;
	}else{ 	//验证输入用户帐号是否存在+验证输入帐号和邮箱是否匹配
		var returnObj='';
		$.ajax({
	 		type:"GET",
			url:"<%=path%>/login/checkEmailCode.do",
			data: {
				userCode:userCode,
				emailCode:emailCode
			},
			dataType:"json",
			async : false, //同步执行
			success:function(data){
				if(data.success){
					returnObj = true;
				} else {
					if(data.msg=="no_user"){
						var userObj = $("#userCode");
						userObj.next("div").find(".tips-ok").hide();
						userObj.next("div").find(".tipsCur").hide();
						userObj.next("div").find(".tips-errow").show();
						returnObj = false;
					} else if(data.msg=="error_pass"){
						var userObj = $("#emailCode");
						userObj.next("div").find(".tips-ok").hide();
						userObj.next("div").find(".tipsCur").hide();
						userObj.next("div").find(".tips-errow").show();
						returnObj = false;
					} else if(data.msg=="no_access"){
						 swal('邮箱未认证，服务器操作失败!');
						 returnObj = false;
					}
				}
			},error:function(data){
			}
		 });
		 return returnObj;
	}
	return true;
}
 </script>
</html>
